import { getLabel, timeConvert } from 'jdf-util';

/*
 * @Author: lirl
 * @Date: 2023-12-14 17:02:41
 * @Description: 公共字段配置文件
 */
// 主办单位
const units = (options) => ({
  formElCode: 'units',
  colSpan: 8,
  elType: 'select',
  options,
  formatter: (val) => getLabel(options, val),
  attrs: {
    clearable: false,
  }
});

// 拟稿人
const principal = {
  formElCode: 'principal',
  colSpan: 8,
};

// 拟稿部门
const department = {
  formElCode: 'department',
  colSpan: 8,
};

// 起草时间
const createTime = {
  formElCode: 'createTime',
  colSpan: 8,
  formatter: (val) => timeConvert(val, 'YYYY年M月D日')
};

// 编号
const serialNumber = {
  formElCode: 'serialNumber',
  colSpan: 8,
};

// 密级
const secret = {
  formElCode: 'secret',
  colSpan: 8,
  elType: 'select',
  isDict: true,
  attrs: {
    clearable: false,
  }
};

// 缓急
const urgencys = {
  formElCode: 'urgencys',
  colSpan: 8,
  elType: 'select',
  isDict: true,
  attrs: {
    clearable: false,
  }
};

// 联系人
const contract = {
  formElCode: 'contract',
  colSpan: 8,
};

// 联系方式

const contractPhone = {
  formElCode: 'contractPhone',
  colSpan: 8,
};

// 标题
const title = {
  formElCode: 'title',
  colSpan: 24,
  attrs: {
    maxlength: 200,
  }
};
// 主送
const mainSend = {
  formElCode: 'mainSend',
  colSpan: 24,
  sendOrg: true,
  attrs: {
    'suffix-icon': 'iconfont icon-zuzhi'
  }
};

// 抄送
const copySend = {
  formElCode: 'copySend',
  colSpan: 24,
  sendOrg: true,
  attrs: {
    'suffix-icon': 'iconfont icon-zuzhi'
  }
};

// 空白占位
const empty = (span) => ({
  colSpan: span
});

// 会签部门
const countersign = (groupCode) => ({
  formElCode: 'countersign',
  colSpan: 24,
  visibleField: 'groupIdentityTreeVisible',
  elType: 'personOrOrg',
  attrs: {
    'suffix-icon': 'iconfont icon-zuzhi'
  },
  treeAttrs: {
    groupCode,
    treeId: sessionStorage.getItem('treeId'),
    // 是否多选，默认false
    multiple: true,
    // 如果是多选，是否在选中节点后，在左侧树中移除选中的节点，multiple属性为true时生效，默认false
    multipleSelectRemoveLeft: true,
    // 是否可搜索，默认false
    filterable: true,
    // 弹出框的标题，默认为'选择'
    dialogTitle: '选择会签部门',
    // 是否隐藏人员
    isHiddenIdentity: true,
    // 展开的层级，为-1时默认不展开，为0时展开第一层...，依此类推, 默认 1
    expandLevel: 0,
    // 搜索输入框的属性
    searchInputAttrs: {
      placeholder: '请选择组织',
      'prefix-icon': 'el-icon-search'
    },
  }
});

// 附件信息
const attachment = {
  formElCode: 'attachment',
  colSpan: 24,
  attrs: {
    maxlength: 200,
  }
};

// 备注
const memo = {
  formElCode: 'memo',
  colSpan: 24,
  attrs: {
    type: 'textarea',
    maxlength: 400,
  }
};

export {
  units,
  principal,
  createTime,
  serialNumber,
  secret,
  urgencys,
  contract,
  contractPhone,
  title,
  mainSend,
  copySend,
  empty,
  countersign,
  attachment,
  memo,
  department,
};
